Skip to content

Add guide on how to emit events properly#88

Open
nwakaku wants to merge 1 commit intocedra-labs:mainfrom
nwakaku:event-indexing
Open

Add guide on how to emit events properly#88
nwakaku wants to merge 1 commit intocedra-labs:mainfrom
nwakaku:event-indexing

Conversation

@nwakaku
Copy link
Copy Markdown

@nwakaku nwakaku commented Dec 29, 2025

Cedra Builders Forge - Submission

Season 1

📋 Task Information

Task Title: Event Indexing Guide #63

Issue Link: #63

Telegram: @Wizzy2304


✅ Checklist

  • Commented "I'm taking this task" on the issue before starting
  • This PR contains ONE task only
  • All work is original (no copy-paste)
  • Code compiles without errors and all tests pass
  • Includes README, tests, and documentation
  • Will share PR in Cedra Builders Telegram

📝 What Was Built

Added a guide: "How to Emit Events Properly" in guides/how-to-emit-events.md. The guide covers:

  • Understanding events: purpose and use cases (indexing, frontend integration, analytics)
  • Event structure: Event struct, EventHandle, and emission process
  • Step-by-step implementation: 5 steps with Move code examples
    • Importing required modules
    • Defining event structs with proper abilities
    • Creating EventHandle in resources
    • Initializing EventHandle
    • Emitting events correctly
  • Complete working example: token transfer contract with events
  • Best practices: 4 recommendations for proper event design
  • Common pitfalls: 4 mistakes with solutions:
    1. Missing drop and store abilities
    2. Emitting events before state changes
    3. Not initializing EventHandle
    4. Using non-serializable types

The guide is concise (~528 words) and focuses on essential information for developers implementing events in Move contracts on Cedra.

Task Issue

[Link to task issue]

Testing Instructions

  1. Review the guide:

    cat guides/how-to-emit-events.md
  2. Verify Move code examples:

    • Ensure examples use correct Cedra Framework imports (cedra_framework::event, cedra_framework::account)
    • Check that event structs have drop and store abilities
    • Verify EventHandle initialization and emission syntax
  3. Test with a real contract (optional):

    # Navigate to referral example which uses events
    cd referral/contract
    
    # Compile and verify event implementation
    cedra move compile --named-addresses referral_example=default
  4. Validate markdown formatting:

    • Check that code blocks render correctly
    • Verify links to external resources work
    • Ensure the guide is readable and well-structured
  5. Cross-reference with existing examples:

    • Compare guide examples with referral/contract/sources/referal.move which demonstrates event emission
    • Verify consistency with actual Cedra Framework event APIs

Dependencies or Setup Required

  • None. The guide is documentation only and requires no additional setup.
  • For testing code examples:
    • Cedra CLI installed
    • Access to Cedra testnet or mainnet
    • Cedra Framework dependencies in Move.toml
    • A Move development environment for compiling contracts

@nwakaku
Copy link
Copy Markdown
Author

nwakaku commented Jan 12, 2026

Hi @ya-dvorovenko

I am one of the winner of the cedra builder forge, thanks to the team for the program

my telegram username is @Wizzy2304

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant